package com.slz3.business.module.configManagement.conZoneType.domain;

import com.slz3.business.frame.enums.AppVersionEnum;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import com.slz3.business.module.configManagement.conZoneManage.enums.ConZoneManageLinkedTypeEnum;
import com.slz3.business.module.configManagement.conZoneType.enums.ConZoneTypePositionEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.UUID;

import static javax.persistence.EnumType.STRING;

/**
 * 专区类型
 */
@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public class ConZoneTypeEntity extends DomainEntity {

    /**
     * 上级专区
     */
    private UUID fkUpperZone;

    /**
     * 模板（外键）
     */
    @NotNull(message = "模板必须非空!", groups = {Add.class, Modify.class})
    private UUID fkZoneTemplate;

    /**
     * 编号
     */
    @Column(length = 80)
//    @NotNull(message = "serNum 必须非空!", groups = {Add.class, Modify.class})
//    @Length(min = 1, max = 80, message = "serNum 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serNum;

    /**
     * 备注
     */
    @Basic(fetch = FetchType.LAZY)
    @Type(type = "text")
    private String serMemo;

    /**
     * 审核状态
     */
    @Enumerated(STRING)
//    @NotNull(message = "serAudit 必须非空!", groups = {Add.class})
//    @Null(message = "serAudit 必须为空!", groups = {Modify.class})
    private AuditFlag serAudit;

    /**
     * 启用状态
     */
    @Enumerated(STRING)
//    @NotNull(message = "serUsing 必须非空!", groups = {Add.class})
//    @Null(message = "serUsing 必须为空!", groups = {Modify.class})
    private UsingFlag serUsing;

    /**
     * 标签
     */
    private String serLabels;

    /**
     * 文件 url 地址
     */
    private String serFileUrl;

    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "TEXT")
    private String serEditorContent;

    /**
     * 名称（中文）
     */
    @NotNull(message = "名称（中文）必须非空!", groups = {Add.class, Modify.class})
    @Length(min = 1, max = 80, message = "名称（中文）必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serName;

    /**
     * 名称（英文）
     */
    private String serNameEn;

    /**
     * 名称（背景图片）Url
     */
    private String serNameBgImgUrl;

    /**
     * 排序号
     */
    @NotNull(message = "排序号 必须非空!", groups = {Add.class, Modify.class})
    private Integer serSortNumber;

    /**
     * 专区大图
     */
    private String serBigImgUrl;

    /**
     * 定位【枚举】位置
     */
    @NotNull(message = "专区位置 必须非空!", groups = {Add.class, Modify.class})
    @Enumerated(STRING)
    private ConZoneTypePositionEnum enuPosition;

    @NotNull(message = "App 版本 必须非空!", groups = {Add.class, Modify.class})
    @Enumerated(STRING)
    private AppVersionEnum enumAppVersion;

    /**
     * 关联类型
     */
    @Enumerated(STRING)
    private ConZoneManageLinkedTypeEnum enumRelevanceType;

    /**
     * 关联对象
     */
    private UUID fkRelevanceObj;


}
